	<?php
	$roomID = $_GET["roomID"];
	$studentID = $_GET['studentID'];
	
	$con = mysql_connect("localhost","root","");
	if (!$con) {
		die('Could not connect: ' . mysql_error());
	}
	mysql_select_db("ciu196", $con);
	
	$sql = "
	SELECT studentID 
	FROM  `helpqueue` 
	WHERE roomID =  '$roomID'
	ORDER BY TIME DESC";
	
	$res = mysql_query($sql,$con);	
	if(!$res) {
		die('Error: couldnt select from the helpqueue' . mysql_error());
	} 
	
	$count = 0;
	$found = false;
	while($row = mysql_fetch_array($res)) {
		$count++;
		if($row[0] == $studentID) {
			found = true;
			break;
		}
	}
	
	if($found) {
		echo "In queue position: " . $count;
	} else {
		echo "User is not in queue";
	}
	
	mysql_close();
?>